CC=/usr/bin/cc
LEX=/usr/bin/lex
YACC=/usr/bin/yacc

CFLAGS = -c


all: table
	@$(CC) -DDEBUG lex.yy.c y.tab.c libtable.o -o coolinary
	@echo "Building coolinary"

parser: 
	@$(LEX) -i coolinary.l
	@echo "(LEX) coolinary"
	@$(YACC) -d coolinary.y
	@echo "(YACC) coolinary"

table: parser
	@$(CC) table.c $(CFLAGS) -o libtable.o
	@echo "(CC) libtable"

clean:
	@echo "Cleaning up build directory."
	@find . -name lex.yy.c -print | xargs -r rm
	@find . -name y.tab.c -print | xargs -r rm
	@find . -name y.tab.h -print | xargs -r rm
	@find . -regex ".*\.*[o~]" -print |xargs -r rm 
	@rm coolinary
